<template>
  <!-- 树形结构 -->
  <el-row type="flex" justify="space-between" style="width:100%">
    <el-col>
      <span :span="12" :style="{fontWeight:isCompany?'7000':''}">{{ treeNode.name }}</span>
    </el-col>
    <el-col :span="4">
      <el-row type="flex" justify="end">
        <el-col>
          <span>{{ treeNode.manager }}</span>
        </el-col>
        <el-col>
          <el-dropdown>
            <span>操作 <i class="el-icon-bottom" /> </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                v-show="checkPermission('add-department')"
                @click.native="addFn"
              >添加子部门</el-dropdown-item>
              <!-- <el-dropdown-item v-if="!isCompany">编辑部门</el-dropdown-item> -->
              <!-- 第二种写法 -->
              <el-dropdown-item
                v-show="checkPermission('edit-department')"
                v-if="isCompany===false"
                @click.native="editFn"
              >编辑部门</el-dropdown-item>
              <!-- isCompany的默认值为false，所以取反就是显示 -->
              <el-dropdown-item
                v-show="checkPermission('del-department')"
                v-if="!isCompany"
                @click.native="delFn"
              >删除部门</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
export default {
  props: {
    treeNode: {
      type: Object,
      required: true
    },
    isCompany: { // true表示渲染公司名
      type: Boolean,
      default: false// 默认值为false，v-if的false就是不删除
    }
  },
  methods: {
    addFn() {
      console.log(111)
      // 子穿父，通知父组件，需要显示新增部门
      this.$emit('addEvent', this.treeNode)
    },
    delFn() {
      this.$emit('delEvent', this.treeNode.id)
    },
    editFn() {
      this.$emit('editEvent', this.treeNode)
    }
  }
}
</script>

<style>

</style>
